Page({
  data: {
    password: [],
    password2: [],
    hint:'请输入密码',
    Length:4,
    ispassword:false//是否显示星号
  },
  jumpPage:function(options){
    wx.switchTab({
      url:'../../pages/deom3/deom3',
    })
  },
  onLoad: function () {
  },
  keyword:function(e){
    let that = this;
    let id = e.currentTarget.dataset.id
    let password = that.data.password
    let password2 = that.data.password2
    password.push(id);
    if (password.length == this.data.Length) {
      if (password.join("") == password2.join("")){
        wx.showToast({
          title: '提交成功',
          icon: 'none',
          duration: 1000,
        })
      } else if (password.join("") != password2.join("") && password2.join("") != ''){
        that.unlike()
      }else{
        password2 = password
        that.again()
      }
    }
    that.setData({
      password: password,
      password2: password2
    })
    
  },
  again:function(e){
    let that = this
    setTimeout(function () {
      that.data.password = []
      console.log('确认输入密码')
      that.setData({
        password: that.data.password,
        hint:'确认输入密码'
      })
    }, 500);
  },
  unlike: function (e) {
    let that = this
    setTimeout(function () {
      that.data.password = []
      that.data.password2 = []
      console.log('两次输入的密码不正确')
      that.setData({
        password: that.data.password,
        password2: that.data.password2,
        hint: '两次输入的密码不正确'
      })
    }, 500);
  },
  cancel:function(e){
    let that = this;
    let password = that.data.password
    password = []
    that.setData({
      password: password
    })
  },
  delete:function(e){
    let that = this;
    let password = that.data.password
    password.pop()
    that.setData({
      password: password
    })
  }
})
